<template>
	<div class="SystemLogStoreContent">
		<div class="systemParameterPageBox">
			<div class="pageConfigBox">
				<div class="pageConfigBoxTitle">
					<div class="titleText">日志存储</div>
				</div>
				<div class="pageConfigBoxContent">
					<div class="pageConfigBoxContentItem">
						<div class="form_text">日志存储时段</div>
						<div class="form_item">
							<el-select v-model="logConfig.logFrequency" placeholder="请选择" @change="handleSelect_log">
								<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
							</el-select>
						</div>
						<div class="form_hint">提示：只保存选项时间段内的日志，请根据系统的使用情况和存储容量进行合理的设置</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
import {
	system_get_logConfig,
	system_update_logConfig,
} from "@/utils/request/api";
export default {
	name: "SystemLogStore",
	data() {
		return {
			// 下拉数据（下拉时间）
			options: [
				{
					value: "1",
					label: "1天",
				},
				{
					value: "3",
					label: "3天",
				},
				{
					value: "7",
					label: "7天",
				},
				{
					value: "15",
					label: "15天",
				},
				{
					value: "30",
					label: "30天",
				},
				{
					value: "60",
					label: "60天",
				},
				{
					value: "90",
					label: "90天",
				},
				{
					value: "180",
					label: "半年",
				},
        {
          value: "365",
          label: "一年",
        },
			],
			// 日志存储配置
      logConfig: {
        id: "",
        systemnKey: "",
				logFrequency: "",
			},
		};
	},
	create() {},
	mounted() {
		this.getAllParameter();
	},
	methods: {
		// 日志存储参数改变
		handleSelect_log() {
			console.log(this.logConfig.logFrequency);
			system_update_logConfig({
				id: this.logConfig.id,
        systemnKey: this.logConfig.systemnKey,
				systemValue: this.logConfig.logFrequency,
			}).then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.$msg.success("日志清除频率设置成功！");
				} else {
					this.$msg.error("日志清除频率设置失败！");
				}
			});
		},
		// 查询日志存储的参数配置
		getAllParameter() {
			system_get_logConfig().then((res) => {
				console.log(res);
				if (res.code == 200) {
					this.logConfig.id = res.data.id;
					this.logConfig.systemnKey = res.data.systemnKey;
					this.logConfig.logFrequency = res.data.systemValue;
				}
			});
		},
	},
};
</script>
<style lang="less" scoped>
.SystemLogStoreContent {
	width: 100%;
	height: 100%;
	background: #ffffff;
	overflow: hidden;
	.systemParameterPageBox {
		width: 103%;
		height: 100%;
		padding: 12px 20px;
		box-sizing: border-box;
		background: #ffffff;
		overflow-y: scroll;
		.pageConfigBox {
			width: 100%;
			display: flex;
			flex-direction: column;
			justify-content: flex-start;
			align-items: flex-start;
			.pageConfigBoxTitle {
				width: 100%;
				height: 54px;
				border-bottom: 1px solid #eee;
				display: flex;
				flex-direction: row;
				justify-content: flex-start;
				align-items: center;
				.titleText {
					width: 145px;
					line-height: 36px;
					font-size: 16px;
					text-align: center;
					background: #eee;
				}
			}
			.pageConfigBoxContent {
				width: 100%;
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: center;
				.pageConfigBoxContentItem {
					width: 90%;
					height: 68px;
					display: flex;
					flex-direction: row;
					justify-content: flex-start;
					align-items: center;
					.form_text {
						width: 172px;
						font-size: 16px;
					}
					.form_item {
						width: 24%;
						height: 40px;
						font-size: 16px;
						margin: 0 24px;
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						align-items: center;
						/deep/ .el-select {
							width: 70%;
						}
					}
					.form_item_input {
						width: 24%;
						height: 40px;
						font-size: 16px;
						margin: 0 24px;
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						align-items: center;
						/deep/ .el-input {
							width: 70%;
						}
						[class*="wj-button-"] {
							font-size: 16px;
							padding: 10px 18px;
						}
					}
					.form_hint {
						width: 48%;
						height: 40px;
						margin-left: 18px;
						font-size: 14px;
						color: #363636;
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						align-items: center;
					}
				}
			}
		}
	}
}
</style>
